<template>
<div><el-dialog
  title="修改"
  :visible.sync="visible"
  :before-close="handleClose">
  <el-form
          :model="user" 
          status-icon
          ref="addForm"
          label-width="100px"
        >
          <el-form-item label="用户名">
            <el-input type="text" v-model="user.userName"></el-input>
          </el-form-item>
          <el-form-item label="密码">
            <el-input
              type="password"
              v-model="user.userPass"
              autocomplete="off"
            ></el-input>
          </el-form-item>
         
         
        </el-form>
  <span slot="footer" class="dialog-footer">
    <el-button @click="visible = false">取 消</el-button>
    <el-button type="primary" @click="update">确 定</el-button>
  </span>
</el-dialog>
</div>
  
</template>

<script>
import {updateUser} from '../../service/user'
import { mapActions,mapMutations,mapState } from 'vuex';
export default {
    data(){
        return {
        }
    },
    computed:{
        visible:{
            get(){
                return this.updateVisible;
            },
            set(updateVisible){
                this.setUpdateVisible(updateVisible);
            }
        },
        ...mapState('user',['updateVisible','user'])
    },
    methods:{
        async update(){
            this.visible = false;
            await updateUser(this.user);
            this.setUsers();
        },
        ...mapMutations('user',['setUser','setUpdateVisible']),
        ...mapActions('user',['setUsers'])
    }
}
</script>

<style>

</style>